package com.fanjun.learning.multithread.Activity_Object_Pattern;

/**
 * Created by fanjun on 16/10/17.
 */
public class MakerClientThread extends Thread {
    private final char fillChar;
    private final ActivityObject activityObject;

    public MakerClientThread(String name, ActivityObject activityObject) {
        super(name);
        this.fillChar = name.charAt(0);
        this.activityObject = activityObject;
    }

    @Override
    public void run() {
        try {
            for (int i = 0; true; i++) {
                Result result = activityObject.makeString(i, fillChar);
                Thread.sleep(10);
                String value = (String) result.getValue();
                System.out.println(Thread.currentThread().getName() + ": value = " + value);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
